﻿using RimWorld;
using Verse;

namespace RimZombieGirl
{
    public class HediffComp_CurseProgress : HediffComp
    {
        public override void CompPostTick(ref float severityAdjustment)
        {
            base.CompPostTick(ref severityAdjustment);

            if (Pawn.Dead) return;

            if (Find.TickManager.TicksGame % 60000 != 0)
                return;

            // 获取诅咒免疫值
            float immunity = parent.pawn.GetStatValue(DefDatabase<StatDef>.GetNamed("RI_CurseImmunity"));
            float dailyChange = 0.03f - immunity/100;

            parent.Severity += dailyChange;

            // 如果达到100%，立刻死亡
            if (parent.Severity >= 1f)
            {
                Pawn.Kill(new DamageInfo(DamageDefOf.Rotting, 9999, instigator: null, weapon: null));
                Messages.Message($"{Pawn.LabelShort} 被诅咒彻底吞噬而死。".Translate(), Pawn, MessageTypeDefOf.NegativeHealthEvent);
            }
        }
    }

    public class HediffCompProperties_CurseProgress : HediffCompProperties
    {
        public HediffCompProperties_CurseProgress()
        {
            this.compClass = typeof(HediffComp_CurseProgress);
        }
    }
}
